      SUBROUTINE TAVISPAK1(KREQMT,ELEMS,ANGREQ,LUERR,IERR)
      IMPLICIT REAL*8 (A-H,O-Z)
C
C THIS ROUTINE IS PART OF TOSS'S TAVISPAK SET OF SUBROUTINES. IT
C CHECKS TAVISPAK'S INPUT VALUES TO VERIFY THAT THEY SATISFY THE
C REQUIREMENTS STATED IN TAVISPAK'S PROLOGUE.
C
C***********************************************************************
C
C BY C PETRUZZ0, GSFC/742,  1/86.
C        MODIFIED....
C
C***********************************************************************
C
      REAL*8 ELEMS(5)
      LOGICAL OKSMA,OKECC,OKREQMT
      REAL*8 PITESTMIN/0.D0/
      REAL*8 PI     / 3.141592653589793D0 /
      REAL*8 TWOPI  / 6.283185307179586D0 /
      REAL*8 DEGRAD / 57.29577951308232D0 /
C
      IERR = 0
      IF(PITESTMIN.EQ.0.D0) THEN
        PITESTMIN =  PI - 1.D-4/DEGRAD
        PITESTMAX =  PI + 1.D-4/DEGRAD
        ZEROTEST =     1.D-4/DEGRAD
        END IF
C
C CHECK FOR VALID REQUIREMENT SELECTION.
C
      OKREQMT = KREQMT.EQ.1  .OR.  KREQMT.EQ.2  .OR.  KREQMT.EQ.3
      IF(.NOT.OKREQMT) THEN
        IERR = 1
        GO TO 9999
        END IF
C
C CHECK SMA AND ECC.
C
      OKSMA = ELEMS(1).GT.0.D0
      OKECC = 0.D0.LE.ELEMS(2) .AND. ELEMS(2).LT.1.D0
      IF(.NOT.(OKSMA.AND.OKECC)) THEN
        IERR = 2
        GO TO 9999
        END IF
C
C FOR HORIZON AVOIDANCE OPTION, VERIFY PERIGEE RADIUS EXCEEDS EARTH
C RADIUS AND (SOLID EARTH ANGLE + ANGREQ) IS IN 0 TO PI RANGE.
C
      IF(KREQMT.EQ.1) THEN
        SMA = ELEMS(1)
        ECC = ELEMS(2)
        RPERIGEE = SMA*(1.D0-ECC)
        REARTH = CONST(53)
C
        IF(RPERIGEE.LT.REARTH) THEN
          IERR = 6
          GO TO 9999
          END IF
C
        ESOLID = DASIN(REARTH/RPERIGEE)
        TEMP = ESOLID + ANGREQ
        IF(TEMP.LT.0.D0 .OR. TEMP.GT.PITESTMAX) THEN
          IERR = 5
          GO TO 9999
          END IF
C
        END IF
C
C FOR VELOCITY VECTOR AVOIDANCE AND ZENITH SEPARATION OPTIONS, VERIFY
C ANGLE IS IN 0 TO PI RANGE.
C
      IF(KREQMT.EQ.2 .OR. KREQMT.EQ.3) THEN
        IF(ANGREQ.LT.0.D0 .OR. ANGREQ.GT.PITESTMAX) THEN
          IERR = 7
          GO TO 9999
          END IF
        END IF
C
 9999 CONTINUE
      RETURN
      END
